package exp5;

import java.util.Arrays;

public class ArrayReverser {
    private int[] data;

    public ArrayReverser(int[] data) {

        if (data != null) {
            this.data = data;
        }
    }

    int[] getData() {
        return data;
    }

    void setData(int[] data) {
        if (data != null) {
            this.data = data;
        }
    }

    @Override
    public String toString() {
        return "ArrayReverser{" +
                "data=" + Arrays.toString(data) +
                '}';
    }

    void reverse() {
        int a;
        for (int i = 0; i <= this.data.length / 2 - 1; i++) {
            a = this.data[i];
            this.data[i] = this.data[this.data.length - 1 - i];
            this.data[this.data.length - 1 - i] = a;
        }
    }
}
